<template>
  <div class="boxPay">
    <div class="tops">
      <img
        src="../../assets/socketImage/back.png"
        style="margin-left: 12px"
        width="40px"
        height="40px"
        alt=""
        @click="handleBack"
      />
      <h2 style="margin-left: 263px">收银台</h2>
    </div>
    <div class="moneys">
      <div class="pay">
        <p>请支付金额</p>
        <h2 style="color: #417de6">
          <strong style="font-size: 30px">￥</strong>{{ payMoney?.toString().padStart(0, '0') }}
        </h2>
      </div>
      <div class="contentPay">
        <ul>
          <li>
            <p>服务类型:</p>
            {{ ShopName }}
          </li>
          <li>
            <p>服务医生:</p>
            不指定
          </li>
          <li>
            <p>服务价格:</p>
            <span>￥{{ payMoney?.toString().padEnd(0.0, '0') }} / 次</span>
          </li>
        </ul>
      </div>
    </div>
    <div class="FangShi">
      <p style="font-size: 27px; padding-left: 20px">请选择支付方式</p>
      <div class="Zhi">
        <img
          src="../../assets/socketImage/alipay.png"
          width="70px"
          style="margin-left: 20px"
          height="70px"
          alt=""
        />
        <span style="font-size: 30px; padding-right: 300px">支付宝</span>
        <img
          src="../../assets/socketImage/checks.png"
          style="margin-right: 50px"
          alt=""
          width="50px"
          height="50px"
        />
      </div>
    </div>
    <button @click="handlePay" class="pays">立即支付</button>
  </div>
</template>
<style lang="scss" scoped>
.boxPay {
  width: 100%;
  height: 1334px;
  display: flex;
  background-color: #eee;
  flex-direction: column;
}
.tops {
  height: 90px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
}
.moneys {
  width: 92%;
  height: 450px;
  margin: 20px auto;
  background-color: #ffffff;
  .pay {
    display: flex;
    align-items: center;
    flex-direction: column;
    height: 200px;
    line-height: 75px;
    border-bottom: 1px solid #c9c9c9;
    p {
      font-size: 28px;
    }
    h2 {
      font-size: 60px;
    }
  }
}
.contentPay {
  ul {
    display: flex;
    margin-left: 40px;
    flex-direction: column;
    li {
      font-size: 26px;
      display: flex;
      margin-top: 10px;
      line-height: 65px;
      p {
        margin-right: 9px;
      }
    }
  }
}
.Zhi {
  margin: auto;
  padding: 0 20px;
  width: 92%;
  display: flex;
  height: 100px;
  line-height: 100px;
  justify-content: space-between;
  margin-top: 15px;
  align-items: center;
  background-color: #ffffff;
}
.pays {
  margin-top: 20px;
  margin: 20px auto;
  width: 600px;
  height: 80px;
  background-color: #b5cbf8;
  font-size: 34px;
  border: none;
  color: white;
  border-radius: 20px;
}
</style>

<script setup lang="ts">
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import Mock from 'mockjs'
import axios from 'axios'

const route = useRoute()
const router = useRouter()
const payMoney = ref(route.query.money)
const ShopName = ref(route.query.name)

const handleBack = () => {
  // router.push({
  //   path: '/home',
  // })
  router.back();
}
const handlePay = async () => {
  await axios
    .get('/api/pay', {
      params: {
        id: Mock.Random.id(),
        price: payMoney.value,
      },
    })
    .then((res) => {
      console.log(res)
      window.open(res.data.result)
    })
}
</script>
